package com.tuoyu.peopletest.view.custom;

import com.github.mikephil.charting.formatter.DefaultValueFormatter;

import java.text.DecimalFormat;

public class CustomMPAValueFormatter extends DefaultValueFormatter {

    private final static String TAG = "CustomMPAValueFormatter";
    /**
     * decimalformat for formatting
     */
    protected DecimalFormat mFormat;

    /**
     * the number of decimal digits this formatter uses
     */
    protected int digits;

    public CustomMPAValueFormatter(int digits) {
        super(digits);
        this.digits = digits;

        StringBuffer b = new StringBuffer();
        for (int i = 0; i < digits; i++) {
            if (i == 0)
                b.append(".");
            b.append("0");
        }

        mFormat = new DecimalFormat("###,###,###,##0" + b.toString());
    }

    @Override
    public String getFormattedValue(float value) {

        return mFormat.format(value);
    }

    /**
     * Returns the number of decimal digits this formatter uses or -1, if unspecified.
     *
     * @return
     */
    public int getDecimalDigits() {
        return digits;
    }
}
